import { z } from 'zod';

const GroupSchemas = {
    //获取群聊
    getGroup: z.object({
        query: z.object({
            groupId: z.string().regex(/^\d+$/, "群组ID必须是数字")
        })
    }),
    // 创建群组
    createGroup: z.object({
        body: z.object({
            name: z.string().min(2).max(50),
            description: z.string().max(200).optional()
        })
    }),

    // 邀请好友
    inviteFriend: z.object({
        body: z.object({
            groupId: z.string().regex(/^\d+$/, "群组ID必须是数字"),
            friendId: z.string().regex(/^\d+$/, "好友ID必须是数字"),
        })
    }),

    // 获取/解散群组
    groupIdQuery: z.object({
        query: z.object({
            groupId: z.string().regex(/^\d+$/, "群组ID必须是数字")
        })
    }),

    // 移除成员
    removeMember: z.object({
        query: z.object({
            groupId: z.string().regex(/^\d+$/, "群组ID必须是数字"),
            memberId: z.string().regex(/^\d+$/, "成员ID必须是数字")
        })
    }),

    // 更新群组
    updateGroup: z.object({
        body: z.object({
            groupId: z.string().regex(/^\d+$/, "群组ID必须是数字"),
            name: z.string().min(2).max(50).optional(),
            description: z.string().max(500).optional()
        })
    })
};
export type GetGroupInput = z.infer<typeof GroupSchemas.getGroup>['query'];
export type CreateGroupInput = z.infer<typeof GroupSchemas.createGroup>['body'];
export type InviteFriendInput = z.infer<typeof GroupSchemas.inviteFriend>['body'];
export type UpdateGroupInput = z.infer<typeof GroupSchemas.updateGroup>['body'];
export type GroupIdQuery = z.infer<typeof GroupSchemas.groupIdQuery>['query'];
export type RemoveMemberInput = z.infer<typeof GroupSchemas.removeMember>['query'];

export default GroupSchemas;